/* Autostop
 *
 * Copyright (c) Maciej Gajewski, Grzegorz Latarowski
 * http://code.google.com/p/autostop-automaty-drogowe
 *
 * This program is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License as published by the
 * Free Software Foundation; either version 2 of the License, or (at your
 * option) any later version. NO WARRANTY OF ANY KIND is expressed or implied.
 */

#ifndef IMAGEANALYZER_H
#define IMAGEANALYZER_H

// qt
#include <QThread>
#include <QVariantMap>

// analyzer
#include "analyzer.h"

// local

/// This is main analyzer class. It intilaizes camera, analyzer process and SQL connection,
/// acquires images and anayzes it reporting intersting results into database.
/// Use the 'run' method to start it. It will return only on clean exit of sime kind,
/// throw exception otherwise.
/// This class inherits QThread and may run as a separate thread
class ImageAnalyzer : public QThread
{
	Q_OBJECT
public:
	
	// construction / destruction
	ImageAnalyzer(){}
	virtual ~ImageAnalyzer(){}
	
	/// Thread entry
	virtual void run();

protected:

	
	/// Intializes analyzer
	void init();
		
	/// Reports object to database
	void reportObject( pobject_t p_object );
	
	/// Reads process parameters
	void readParams( const QVariantMap& params );
	
	/// Fill image with its own difference from process backgorund
	void prepareDiff( pimage_t pImage );
	
	// data
	pprocess_t _pProcess;		///< Analyzer process
	
	bool	_showDiff;			///< If backgorund/foreground differemnce should be put into image

};

#endif // IMAGEANALYZER_H

// eof


